package dyv;

import java.util.Scanner;



public class Herramientas {
	static Scanner leer = new Scanner(System.in);
	
	public static int [] generarAleatorio( int num, int maximo){
		int [] matriz = new int [num];
		int minimo = 0;
		for(int i=0;i<num;i++)
			matriz[i]=(int)(Math.random()*(maximo-minimo)+minimo);
		return matriz;	
	} 

	public static int [][] generarManual(int num){
		int[][] listaManual = new int[2][num];
		
		for(int i=0;i<num;i++){
			System.out.println("Introduce la posicion X del punto "+i);
			listaManual[0][i]=leer.nextInt();
			System.out.println("Introduce la posicion Y del punto "+i);
			listaManual[1][i]=leer.nextInt();
		}
		return listaManual;
	}
	
	
//QUICKSORT
	public static void intercambia(int[] v,int [] m, int pos1, int pos2){
		int aux=v[pos1];
		int aux2=m[pos1];
		
		v[pos1]=v[pos2];
		m[pos1]=m[pos2];
		v[pos2]=aux;
		m[pos2]=aux2;
	}
	public static void quicksort(int[] v, int[] m, int li, int ls){
		if (li<ls){
			int pos=divide(v,m,li,ls);
			quicksort(v,m, li, pos-1);
			quicksort(v,m, pos+1, ls);
		}
	}
	public static int divide(int[] v,int []m,  int li, int ls){
		int pivote=v[li];
		int izq=li+1; int der=ls;
		while(izq<der && v[izq]<=pivote ) izq++;
		while (v[der]>pivote) der--;
		while (izq<der){
			intercambia(v,m,izq,der);
			do{izq++;}while(v[izq]<=pivote);
			do{der--;}while(v[der]>pivote);
		}
		intercambia(v,m, li,der);
		return der;
	}
}

